C
C *** LAST REVISED ON 27-OCT-1987 08:19:52.45
C *** SOURCE FILE: [DL.GRAPHICS.LONGLIB]MLIB3.FOR
C
C ************************************************************************
C
C MORE MASTER ROUTINES FOR THE LONGLIB GRAPHICS LIBRARY
C
C THESE ROUTINES ARE FORTRAN 77 COMPATIBLE WITH THE FOLLOWING EXCEPTIONS
C	1. LINES ARE INDENTED WITH TABS (^I).
C	2. TRAILING COMMENTS SEPARATE BY ! ARE USED.
C
C MACHINE DEPENDENCIES
C	1. %REF() IS USED TO CONVERT CHARACTER VARIABLE TO BYTE STRING
C	    EXPECTED BY SYMBOL ROUTINE IN PICHRT AND BARCHR.
C
C ************************************************************************
C
C
	SUBROUTINE PICHRT(X0,Y0,RAD,D,IFLAG,AST,N,VALS,ISH,IWT,
     $		LABELS,NCH,CS,ALEG,T,NT,TCS,DIS,ABC,ICOL)
C
C	ROUTINE TO PLOT A PIE CHART WITH SHADED WEDGES, DESCRIPTIVE
C	LEGENDS AND EXPLODED SLICES.
C
C	WRITTEN:  DGL  AUG 1987
C
C	X0,Y0	(R) CENTER OF PIE CHART
C	RAD	(R) RADIUS OF PIE CHART (RAD>0)
C	D	(R) EXPLODE DISTANCE (D>0)
C	IFLAG	(R) PLOTTING FLAG
C			< 0 DON'T CLOSE PLOT PACKAGE
C			> 0 CLOSE PLOT PACKAGE
C		MAG	> 10000 INIT PLOT PACKAGE
C	(ONE'S DIGIT)   = 1 DON'T USE COLORS
C		        = 2 USE COLORS
C	(HUNDRED'S)	= SCREEN GRAPHICS DEVICE (SEE FRAME)
C	AST	(R) STARTING ANGLE
C	N	(I) NUMBER OF WEDGES
C	VALS	(R) ANGULAR PERCENT OF PIE CHART FOR EACH WEDGE
C		     DIMENSIONED VALS(N), WEDGES INCREMENT CCW
C		     IF VALS(I)<0 THEN WEDGE IS EXPLODED OUT FROM CENTER
C		     D DISTANCE
C	ISH	(R) SHADE OPTION FOR EACH WEDGE DIMENSIONED ISH(N)
C			VALUE OF ISH   SHADE PATTERN
C			    0		 NO SHADING (OUTLINE ONLY)
C			    1		 -45 DEG SOLID LINES
C			    2		 HORIZONTAL SOLID LINES
C			    3		 +45 DEG SOLID LINES
C			    4		 VERTICAL SOLID LINES
C			    5		 -45 DEG DOTTED LINES
C			    6		 HORIZONTAL DOTTED LINES
C			    7		 +45 DEG DOTTED LINES
C			    8		 VERTICAL DOTTED LINES
C			    9		 +/- 45 DEG DOTTED LINES
C			   10		 HORIZONTAL/VERTICAL DOTTED LINES
C			   11		 +/- 45 DEG SOLID LINES
C			   12		 HORIZONTAL/VERTICAL SOLID LINES
C	IWT	(I) PEN WIDTH FOR WEDGE OUTLINES (SEE NEW PEN)
C	LABELS	(C) LABELS FOR WEDGES DIMENSIONED LABELS(N)
C	NCH	(I) MAXIMUM NUMBER OF CHARACTERS IN LABELS
C	ALEG	(R) SIZE OF LEGEND BOX 
C		    < 0 LEGENDS LOCATED BELOW PIE CHART
C		    = 0 NO LEGEND (LABELS IGNORED)
C		    > 0 LEGENDS LOCATED AROUND PIE CHART
C	(MAG)	    > 98 LEGEND WITH NO BOXED AREA
C	CS	(R) LEGEND CHARACTER SIZE
C	T	(B) TITLE
C	NT	(I) CHARACTERS IN TITLE
C	TCS	(R) TITLE SIZE
C		    IF TCS <0 THEN INPUT POSITIONS IN ABC USED
C	ABC	(R) LOCATION OF LOWER-LEFT CORNER OF EACH LEGEND
C		    LINE (USED IF TCS<0)
C			ABC(1)=X POSITION LEGEND LABEL 1
C			ABC(2)=Y POSITION LEGEND LABEL 1
C			ABC(3)=X POSITION LEGEND LABEL 2
C			ABC(4)=Y POSITION LEGEND LABEL 2
C			 ...
C	DIS	(R) SHADING LINE DISTANCE
C	ICOL	(I) COLOR ARRAY
C		    ICOL(1) = TITLE COLOR (RETURN)
C		    ICOL(2) = LEGEND LABEL COLOR
C		    ICOL(3) = COLOR OF WEDGE 1
C		     ...          ...        2
C
	DIMENSION VALS(1),ISH(1),IWT(1),ICOL(1),ABC(1)
	INTEGER T(1)
	CHARACTER*(*) LABELS(1)
C
C	CIRCLE RESOLUTION AND WORK SPACE
C
	PARAMETER (RES=0.1)	! CIRCLE RESOLUTION
	PARAMETER (NWORK=1000)	! WORK SPACE
	DIMENSION W(NWORK)
C
	LOGICAL REPEAT
	DATA DTR/0.0174533/,PI/3.141592654/,REPEAT/.FALSE./
C
C	INTIALIZE ROUTINE AND PLOT PACKAGE IF REQUIRED
C
	IF (IFLAG.EQ.0) THEN
		IF (REPEAT) CALL PLOTND	!CLOSE PLOTTER
		REPEAT=.FALSE.
		RETURN
	ENDIF
C
C	INTIALIZE PLOT PACKAGE
C
	JF=IABS(IFLAG)
	IF (.NOT.REPEAT.AND.JF.LT.10000) THEN
		ILU=JF/100			!GRAPHICS DEVICE CODE
		CALL FRAME(3,ILU,1.5,1.0,1.)	!INTIALIZE
	ELSE
		CALL CTERM(-1)			!PUT TERMINAL IN PLOT MODE
	ENDIF
	JF=MOD(IFLAG,10)			!COLOR FLAG
C
C	MUST HAVE POSITIVE RADIUS
C
	IF (RAD.LE.0.0.OR.N.LT.1) GOTO 200
	SCALE=0.0
	DO 10 I=1,N
		SCALE=SCALE+ABS(VALS(I))
10	CONTINUE
	IF (SCALE.EQ.0.0) GOTO 200
	SCALE=360.0/SCALE
C
	ANG=AST
	DO 100 I=1,N
		IF (VALS(I).EQ.0.0) GOTO 100
		ANG1=ANG+ABS(VALS(I))*SCALE
		X1=X0
		Y1=Y0
		IF (VALS(I).LT.0.0) THEN
			X1=X0+COS((ANG+ANG1)*DTR/2.)*D
			Y1=Y0+SIN((ANG+ANG1)*DTR/2.)*D
		ENDIF
		IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(I+2)),0.,0)
C
C	DO OUTLINE
C
		AN=0.0
		IL=0
		CALL CSHADE(X1,Y1,RAD,ANG,ANG1,RES,1,DIS,
     $			AN,W,IL,IWT(I)*10)
C
C	FILL REGION WITH DESIRED FILL PATTERN
C
		IF (ISH(I).EQ.0) GOTO 90
		AN=45.0*(MOD(ISH(I)-1,4)-1)
		IL=10
		IF (ISH(I).GT.4.AND.ISH(I).LT.11) IL=11
		CALL CSHADE(X1,Y1,RAD,ANG,ANG1,RES,2,DIS,
     $			AN,W,IL,-1)
		IF (ISH(I).GT.8) THEN
			AN=AN+90.
			IL=11
			IF (ISH(I).GT.10) IL=10
			CALL CSHADE(X1,Y1,RAD,ANG,ANG1,RES,2,DIS,
     $				AN,W,IL,-1)
		ENDIF
90		ANG=ANG1
100	CONTINUE
	IF (IL.EQ.11) CALL NEWPEN(0)
C
C	PLOT LEGEND IF SELECTED
C
	IF (ALEG.EQ.0.0) GOTO 160
	IF (ALEG.LT.0.0.OR.TCS.LT.0.0) THEN
	   Y1=Y0-CS*NCH/2.
	   DO 125 I=1,N
		X1=X0-RAD-CS*1.1*N-0.1
		IF (TCS.LT.0.0) THEN
			X1=ABC(2*I-1)
			Y1=ABC(2*I)
		ENDIF
		IF (ABS(ALEG).LT.99.0) THEN
			W(1)=X1
			W(2)=Y1
			W(3)=X1+ABS(ALEG)
			W(4)=Y1
			W(5)=X1+ABS(ALEG)
			W(6)=Y1+ABS(ALEG)
			W(7)=X1
			W(8)=Y1+ABS(ALEG)
			X1=X1+ABS(ALEG)+0.2
			AN=0.0
			IF(JF.EQ.2)CALL PLOT(FLOAT(ICOL(I+2)),0.,0)
			IL=0
			CALL SHADE(W(1),W(2),4,2,1,DIS,AN,
     $				W(9),IL,0.,1.,0.,1.)
			IF (ISH(I).EQ.0) GOTO 120
			AN=45.0*(MOD(ISH(I)-1,4)-1)
			IL=0
			IF (ISH(I).GT.4.AND.ISH(I).LT.11) IL=1
			CALL SHADE(W(1),W(2),4,2,2,DIS,AN,
     $				W(9),IL,0.,1.,0.,1.)
			IF (ISH(I).GT.8) THEN
			    AN=AN+90.
			    IL=1
			    IF (ISH(I).GT.10) IL=0
			    CALL SHADE(W(1),W(2),4,2,2,DIS,AN,
     $				W(9),IL,0.,1.,0.,1.)
			ENDIF
	 	ENDIF
120		CONTINUE
	        IF (IL.EQ.1) CALL NEWPEN(0)
		IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(2)),0.,0)
		CALL SYMBOL(X1,Y1,CS,%REF(LABELS(I)),0.,NCH,-1)
		Y1=Y1+CS*(1.5)
125	   CONTINUE
	ELSE
	  ANG=AST
	  DO 150 I=1,N
	    ANG1=ANG+ABS(VALS(I))*SCALE
C
C	COMPUTE LABEL LENGTH AND TRY TO LOCATE TO LOOK NICE
C
	    W(1)=0.
	    W(2)=0.
	    CALL SYMBOL(W(1),W(2),CS,%REF(LABELS(I)),0.,NCH,-3)
	    R=RAD+CS+0.1
	    IF (VALS(I).LT.0) R=R+D
	    X1=X0+COS((ANG+ANG1)*DTR/2.)*R
	    Y1=Y0+SIN((ANG+ANG1)*DTR/2.)*R
	    IF (X1.LT.X0) X1=X1-W(1)
	    IF (VALS(I).EQ.0.0) GOTO 140
	    IF (ABS(ALEG).LT.99.0) THEN
	        IF (X1.LT.X0) X1=X1-ABS(ALEG)
	        IF (Y1.LT.Y0) Y1=Y1-ABS(ALEG)
		W(1)=X1
		W(2)=Y1
		W(3)=X1+ABS(ALEG)
		W(4)=Y1
		W(5)=X1+ABS(ALEG)
		W(6)=Y1+ABS(ALEG)
		W(7)=X1
		W(8)=Y1+ABS(ALEG)
		X1=X1+ABS(ALEG)+0.2
		AN=0.0
		IF(JF.EQ.2)CALL PLOT(FLOAT(ICOL(I+2)),0.,0)
		CALL SHADE(W(1),W(2),4,2,1,DIS,AN,
     $			W(9),0,0.,1.,0.,1.)
		IF (ISH(I).EQ.0) GOTO 140
		AN=45.0*(MOD(ISH(I)-1,4)-1)
		IL=0
		IF (ISH(I).GT.4.AND.ISH(I).LT.11) IL=1
		CALL SHADE(W(1),W(2),4,2,2,DIS,AN,
     $			W(9),IL,0.,1.,0.,1.)
		IF (ISH(I).GT.8) THEN
		    AN=AN+90.
		    IL=1
		    IF (ISH(I).GT.10) IL=0
		    CALL SHADE(W(1),W(2),4,2,2,DIS,AN,
     $			W(9),IL,0.,1.,0.,1.)
		ENDIF
		   ENDIF
140	    CONTINUE
	    IF (IL.EQ.1) CALL NEWPEN(0)
	    IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(2)),0.,0)
	    CALL SYMBOL(X1,Y1,CS,%REF(LABELS(I)),0.,NCH,-1)
	    Y1=Y1+CS*(1.5)
	    ANG=ANG1
150	  CONTINUE
	ENDIF
C
C	ADD TITLE IF SELECTED
C
160	CONTINUE
	IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(1)),0.,0)
	IF (NT.GT.0) THEN
		X1=0.
		Y1=0.
		CALL SYMBOL(X1,Y1,ABS(TCS),T,0.,NT,-3)
		X1=X0-X1/2.
		Y1=Y0+RAD+CS+0.20
		IF (ABS(ALEG).LT.98.0) Y1=Y1+ABS(ALEG)
		CALL SYMBOL(X1,Y1,ABS(TCS),T,0.,NT,-1)
	ENDIF
C
C	FINISH UP
C
200	CALL PLOT(0.,0.,3)			!PEN UP
	IF (IFLAG.GT.0) THEN
		CALL CTERM(2)			!CLEAR TERMINAL
		CALL PLOTND			!CLOSE PLOT OUTPUT
		REPEAT=.FALSE.
	ENDIF
	IF (IFLAG.LT.0) THEN
		REPEAT=.TRUE.
		CALL CTERM(1)			!PUT TERMINAL IN TEXT MODE
	ENDIF
	RETURN
	END
C
C ************************************************************************
C
	SUBROUTINE BARCHR(VALS,NB,NS,ISH,IFLAG,XLEN,YLEN,VMIN,VMAX,
     $			FORM,NDIV,SP,SLAB,NSLAB,BLAB,NBLAB,CS,
     $			T,NT,BT,NBT,LT,NLT,TCS,ALEG,DIS,IWT,ICOL)
C
C	ROUTINE TO PLOT A BAR CHART WITH SHADED BARS OR SHADED REGIONS
C	BETWEEN LINES WITH DESCRIPTIVE LEGENDS
C
C	WRITTEN:  DGL  AUG 1987
C
C	VALS	(R) VALUE FOR EACH BAR SEGMENT DIMENSIONED VALS(NB,NS)
C		    WHERE NB IS THE NUMBER OF BARS AND NS IS THE
C		    NUMBER OF SEGMENTS IN EACH BAR
C	NB	(I) NUMBER OF BARS/NUMBER OF POINTS (25>NB>0)
C	NS	(I) NUMBER OF SEGMENTS IN EACH BAR/NUMBER OF LINES (10>NS>0)
C	ISH	(R) SHADE OPTION FOR EACH SEGMENT DIMENSIONED ISH(NS)
C			VALUE OF ISH   SHADE PATTERN
C			    0		 NO SHADING (OUTLINE ONLY)
C			    1		 -45 DEG SOLID LINES
C			    2		 HORIZONTAL SOLID LINES
C			    3		 +45 DEG SOLID LINES
C			    4		 VERTICAL SOLID LINES
C			    5		 -45 DEG DOTTED LINES
C			    6		 HORIZONTAL DOTTED LINES
C			    7		 +45 DEG DOTTED LINES
C			    8		 VERTICAL DOTTED LINES
C			    9		 +/- 45 DEG DOTTED LINES
C			   10		 HORIZONTAL/VERTICAL DOTTED LINES
C			   11		 +/- 45 DEG SOLID LINES
C			   12		 HORIZONTAL/VERTICAL SOLID LINES
C	IFLAG	(R) PLOTTING FLAG
C			< 0 DON'T CLOSE PLOT PACKAGE
C			> 0 CLOSE PLOT PACKAGE
C		MAG	> 10000 INIT PLOT PACKAGE
C	(ONE'S DIGIT)   = 1 DON'T USE COLORS
C		        = 2 USE COLORS
C	(TEN'S DIGIT)	= 0 VERTICAL BAR CHART
C			= 1 HORIZONTAL BAR CHART
C			= 2 LINE CHART WITH SHADING BETWEEN LINES
C	(HUNDRED'S)	= SCREEN GRAPHICS DEVICE (SEE FRAME)
C	XLEN	(R) HEIGHT OF CHART
C		    IF XLEN <0 THEN CHART IS PUT IN BOX
C	YLEN	(R) WIDTH OF CHART
C	VMIN	(R) MINIMUM VALUE OF VALS SHOWN ON CHART
C	VMAX	(R) MAXIMUM VALUE OF VALS SHOWN ON CHART
C		    NOTE: IF VMIN=VMAX THEN AUTO SCALING IS USED.
C	FORM	(R) NUMERIC LABEL FORMAT (SEE NUMBER)
C	NDIV	(I) NUMBER OF DIVSIONS ALONG BAR/LINE LENGTH
C		    < 0 LINES ACROSS BAR SPACE SHOWN
C		    = 0 NO DIVISION OR NUMERIC LABELS
C		    > 0 NO LINES ACROSS BAR SPACE SHOWN
C	SP	(R) WIDTH OF BAR
C		    = 0 BARS EVENLY SPACE WITH AUTO SPACING
C		   <> 0 BARS GROUPED IN GROUPS OF INT(SP), WITH SPACING
C			BETWEEN BARS IN GROUPS SPECIFIED BY FRAC(SP)
C	SLAB	(C) SEGMENT LABEL ARRAY DIMENSIONED SLAB(NS)
C	NSLAB	(I) MAXIMUM NUMBER OF CHARACTERS IN SEGMENT LABELS
C	BLAB	(C) BASE LABEL ARRAY DIMENSIONED BLAB(NB)
C	NBLAB	(I) MAXIMUM NUMBER OF CHARACTERS IN BASE LABELS
C	CS	(R) LABEL CHARACTER SIZE
C	T	(B) TITLE ABOVE CHART
C	NT	(I) NUMBER OF CHARACTERS IN TITLE
C	BT	(B) TITLE BESIDE BASE OF BARS
C	NBT	(I) NUMBER OF CHARACTERS IN BT
C	LT	(B) TITLE ALONG SIZE OF BARS
C	NLT	(B) NUMBER OF CHARACTERS IN NLT
C	TCS	(R) TITLE CHARACTER SIZE
C	ALEG	(R) LEGEND LOCATION
C		    ALEG(1)= LEGEND SHADING BOX SIZE 
C			      = 0 NO LEGEND
C			      < 0 LEGEND PLOTTED TO RIGHT OF CHART 
C				  AND ALEG(2),ALEG(3) NOT USED
C			      > 0 ALEG(2),ALEG(3) USED
C		    ALEG(2)= X POSITION OF LOWER LEFT CORNER OF LEGEND
C		    ALEG(3)= Y POSITION OF LOWER LEFT CORNER OF LEGEND
C	DIS	(R) SHADING LINE DISTANCE
C		    > 0 LINE WEIGHTS NOT USED
C		    < 0 LINE WEIGHTS USED
C	IWT	(I) PEN WIDTH ARRAY (0-9)
C		    IWT(1) = AXIS LINE WIDTH
C		    IWT(2) = DIVISION LINE WIDTH
C		    IWT(3) = BAR OUTLINE/LINE WIDTH
C		    IWT(4) = LABEL WIDTH
C		    IWT(5) = TITLE WIDTH (BT,LT)
C		    IWT(6) = TOP TITLE WIDTH
C	ICOL	(I) COLOR ARRAY
C		    ICOL(1) = TOP OF CHART TITLE COLOR (RETURN)
C		    ICOL(2) = BT TITLE COLOR
C		    ICOL(3) = LT TITLE COLOR
C		    ICOL(4) = AXIS TITLE COLOR
C		    ICOL(5) = SLAB COLOR
C		    ICOL(6) = BLAB COLOR
C		    ICOL(7) = SEGMENT COLOR 1
C		    ICOL(8) = SEGMENT COLOR 2
C		     ...          ...
C
	DIMENSION VALS(NB,NS),ISH(NS),ICOL(1),IWT(1),ALEG(1)
	INTEGER T(1),BT(1),LT(1)
	CHARACTER*(*) SLAB(1),BLAB(1)
C
	PARAMETER (NWORK=1000)	! WORK SPACE FOR SHADING
	DIMENSION W(NWORK)
C
	LOGICAL REPEAT
	DATA DTR/0.0174533/,PI/3.141592654/,REPEAT/.FALSE./
C
C	INTIALIZE ROUTINE AND PLOT PACKAGE IF REQUIRED
C
	IF (IFLAG.EQ.0) THEN
		IF (REPEAT) CALL PLOTND	!CLOSE PLOTTER
		REPEAT=.FALSE.
		RETURN
	ENDIF
C
C	INTIALIZE PLOT PACKAGE
C
	JF=IABS(IFLAG)
	IF (.NOT.REPEAT.AND.JF.LT.10000) THEN
		ILU=JF/100			!GRAPHICS DEVICE CODE
		CALL FRAME(3,ILU,1.5,1.0,1.)	!INTIALIZE
	ELSE
		CALL CTERM(-1)			!PUT TERMINAL IN PLOT MODE
	ENDIF
	JFF=MOD(JF,100)/10			!OPTION FLAG
	JF=MOD(JF,10)				!COLOR FLAG
C
	VM=VMIN
	VX=VMAX
	SCALE=VX-VM
	IF (SCALE.LE.0.0) THEN
		VM=VALS(1,1)
		VX=VALS(1,1)
		DO 10 I=1,NB
			DO 10 J=1,NS
				VM=MIN(VALS(I,J),VM)
				VX=MAX(VALS(I,J),VX)
10		CONTINUE
		SCALE=VX-VM
		IF (SCALE.EQ.0.0) SCALE=1.0
	ENDIF
C
C	MAKE CHART AXISES
C
	IF (DIS.LT.0.0) CALL NEWPEN(IWT(1)*10)
	IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(4)),0.,0)
	CALL PLOT(0.,YLEN,3)
	CALL PLOT(0.,0.,2)
	CALL PLOT(ABS(XLEN),0.,2)
	IF (XLEN.LT.0.0) THEN
		CALL PLOT(ABS(XLEN),YLEN,2)
		CALL PLOT(0.,YLEN,2)
	ENDIF
C
C	MAKE AXIS LABELS
C
	ND=IABS(NDIV)
	AM=0.0
	IF (ND.EQ.0) GOTO 50
	IF (DIS.LT.0.0) CALL NEWPEN(IWT(4)*10)
	SCALE=SCALE/FLOAT(ND)
	IF (JFF.NE.1) THEN
C
C	COMPUTE NUMERIC LABEL LENGTHS
C
		DO 15 I=0,ND
			AV=VM+SCALE*I
			X1=0.
			Y1=0.
			CALL NUMBER(X1,Y1,CS,AV,0.,FORM,-3)
			AM=MAX(AM,X1)
15		CONTINUE
C
C	DISPLAY NUMERIC LABELS ON Y AXIS
C
		DO 20 I=0,ND
			AV=VM+SCALE*I
			X1=-AM-CS/2.
			Y1=I*YLEN/ND
			CALL NUMBER(X1,Y1,CS,AV,0.,FORM,-1)
20		CONTINUE
		IF (NDIV.LT.0) THEN
			IF (DIS.LT.0.0) CALL NEWPEN(10)
			DO 25 I=1,ND
				Y1=I*YLEN/ND
				CALL PLOT(0.,Y1,3)
				CALL PLOT(ABS(XLEN),Y1,2)
25			CONTINUE
		ENDIF
	ELSE
C
C	DISPLAY NUMERIC LABELS ON X AXIS
C
		DO 30 I=0,ND
			AV=VM+SCALE*I
			Y1=-CS
			X1=I*ABS(XLEN)/ND
			CALL NUMBER(X1,Y1,CS,AV,0.,FORM,0)
30		CONTINUE
		IF (NDIV.LT.0) THEN
			IF (DIS.LT.0.0) CALL NEWPEN(10)
			DO 35 I=1,ND
				X1=I*ABS(XLEN)/ND
				CALL PLOT(X1,0.,3)
				CALL PLOT(X1,YLEN,2)
35			CONTINUE
		ENDIF
	ENDIF
C
C	MAKE CHART BARS/LINES
C
50	CONTINUE
	IF (YLEN.EQ.0.0.OR.XLEN.EQ.0.0) GOTO 200
	IF (JFF.EQ.1) THEN
		SCALE=ABS(XLEN)/SCALE/FLOAT(ND)
	ELSE
		SCALE=YLEN/SCALE/FLOAT(ND)
	ENDIF
C
	IF (JFF.LT.2) THEN
C
C	MAKE BAR CHART
C
	    VSP=ABS(XLEN)/FLOAT(NB)		! VERTICAL BARS
	    IF (JFF.EQ.1) VSP=YLEN/FLOAT(NB)	! HORIZONTAL BARS
	    WB=(ABS(SP)-INT(ABS(SP)))/2.
	    KK=INT(ABS(SP))
	    IF (KK.EQ.1) KK=0
	    IF (WB.EQ.0.0) WB=VSP*0.4		! AUTO SCALE
	    DO 100 I=1,NB
		DO 75 J=1,NS
			IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(J+6)),0.,0)
C
C	DO AREA OUTLINE
C
			IF (JFF.EQ.1) THEN	! HORIZONTAL BARS
				Y1=(I-0.5)*VSP
				IF (KK.NE.0) THEN
				    K=MOD(I-1,KK)
				    Y1=Y1+(VSP-WB)*
     $					(FLOAT(K)-FLOAT(KK-1)/2.)
				ENDIF
				YY=WB
				IF (J.GT.1) THEN
					AV=0.0
					DO 112 K=1,J-1
						AV=AV+VALS(I,K)
112					CONTINUE
					X1=(AV-VM)*SCALE
					AV=AV+VALS(I,J)
					XX=(AV-VM)*SCALE
				ELSE
					X1=0.0
					XX=(VALS(I,J)-VM)*SCALE
				ENDIF
				W(1)=X1
				W(2)=Y1-YY
				W(3)=XX
				W(4)=Y1-YY
				W(5)=XX
				W(6)=Y1+YY
				W(7)=X1
				W(8)=Y1+YY
			ELSE			! VERTICAL BARS
				X1=(I-0.5)*VSP
				IF (KK.NE.0) THEN
				    K=MOD(I-1,KK)
				    X1=X1+(VSP-WB)*
     $					(FLOAT(K)-FLOAT(KK-1)/2.)
				ENDIF
				XX=WB
				IF (J.GT.1) THEN
					AV=0.0
					DO 113 K=1,J-1
						AV=AV+VALS(I,K)
113					CONTINUE
					Y1=(AV-VM)*SCALE
					AV=AV+VALS(I,J)
					YY=(AV-VM)*SCALE
				ELSE
					Y1=0.0
					YY=(VALS(I,J)-VM)*SCALE
				ENDIF
				W(1)=X1-XX
				W(2)=Y1
				W(3)=X1+XX
				W(4)=Y1
				W(5)=X1+XX
				W(6)=YY
				W(7)=X1-XX
				W(8)=YY
			ENDIF
C
C	OUTLINE AREA
C
			AN=0.0
			IL=0
			IF (DIS.LT.0.0) CALL NEWPEN(10*IWT(3))
			CALL SHADE(W(1),W(2),4,2,1,ABS(DIS),AN,
     $				W(9),IL,0.,1.,0.,1.)
			IF (ISH(J).EQ.0) GOTO 75
C
C	FILL WITH DESIRED PATTEN
C
			AN=45.0*(MOD(ISH(J)-1,4)-1)
			IL=10
			IF (ISH(J).GT.4.AND.ISH(J).LT.11) IL=11
			CALL SHADE(W(1),W(2),4,2,2,ABS(DIS),AN,
     $				W(9),IL,0.,1.,0.,1.)
			IF (ISH(J).GT.8) THEN
			    AN=AN+90.
			    IL=11
			    IF (ISH(J).GT.10) IL=10
			    CALL SHADE(W(1),W(2),4,2,2,ABS(DIS),AN,
     $				W(9),IL,0.,1.,0.,1.)
			ENDIF
75		CONTINUE
100	    CONTINUE
	    IF (IL.NE.10) CALL NEWPEN(0)
	ELSE
C
C	USE SHADING BETWEEN LINES
C
	   VSP=ABS(XLEN)/FLOAT(NB-1)
	   DO 300 J=1,NS
		DO 250 I=1,NB
			X1=(I-1)*VSP
			IF (J.GT.1) THEN
				AV=0.0
				DO 212 K=1,J
					AV=AV+VALS(I,K)
212				CONTINUE
				Y1=(AV-VM)*SCALE
			ELSE
				Y1=(VALS(I,J)-VM)*SCALE
			ENDIF
			W(2*I-1)=X1
			W(2*I)=Y1
250		CONTINUE
		IF (J.EQ.1) THEN
			I=NB+1
			W(2*I-1)=X1
			W(2*I)=0.
			I=I+1
			W(2*I-1)=0.
			W(2*I)=0.
		ELSE
			I=NB
			DO 260 II=1,NB
				I1=NB-II+1
				X1=(I1-1)*VSP
				AV=0.0
				DO 213 K=1,J-1
					AV=AV+VALS(I1,K)
213				CONTINUE
				Y1=(AV-VM)*SCALE
				I=I+1
				W(2*I-1)=X1
				W(2*I)=Y1
260			CONTINUE
			I=2*NB
		ENDIF
		NW=2*I+2
		IF(JF.EQ.2)CALL PLOT(FLOAT(ICOL(J+6)),0.,0)
C
C	PLOT LINE FOR THIS SEGMENT
C
		IF (DIS.LT.0.0) CALL NEWPEN(10*IWT(3))
		IP=3
		DO 275 K=1,I
			CALL PLOT(W(2*K-1),W(2*K),IP)
			IP=2
275		CONTINUE
		IF (ISH(J).EQ.0) GOTO 300
C
C	FILL WITH DESIRED PATTEN
C
		AN=45.0*(MOD(ISH(J)-1,4)-1)
		IL=10
		IF (ISH(J).GT.4.AND.ISH(J).LT.11) IL=11
		CALL SHADE(W(1),W(2),I,2,2,ABS(DIS),AN,
     $			W(NW),IL,0.,1.,0.,1.)
		IF (ISH(J).GT.8) THEN
			AN=AN+90.
			IL=11
			IF (ISH(J).GT.10) IL=10
			CALL SHADE(W(1),W(2),I,2,2,ABS(DIS),AN,
     $				W(NW),IL,0.,1.,0.,1.)
		ENDIF
300	   CONTINUE
	ENDIF
	IF (IL.NE.0) CALL NEWPEN(0)
C
C	ADD BASE LABELS
C
	IF (NBLAB.NE.0) THEN
		IF (DIS.LT.0.0) CALL NEWPEN(10*IWT(4))
		IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(6)),0.,0)
		K=NB
		IF (KK.NE.0) K=MOD(NB-1,KK)
		J=1
		IF (KK.NE.0) J=KK
		DO 320 I=1,K
		  IF (JFF.EQ.1) THEN	! HORIZONTAL BARS
		   Y1=((I-1)*J+0.5)*VSP
		   X1=-CS
		   CALL SYMBOL(X1,Y1,CS,%REF(BLAB(I)),90.,NBLAB,0)
		  ELSE			! VERTICAL ORIENTATION
		   X1=((I-1)*J+0.5)*VSP
		   IF (JFF.EQ.2) X1=(I-1)*J*VSP
		   Y1=-CS
		   CALL SYMBOL(X1,Y1,CS,%REF(BLAB(I)),0.,NBLAB,0)
		  ENDIF
320		CONTINUE
	ENDIF
C
C	PLOT LEGEND IF SELECTED
C
	IF (ALEG(1).EQ.0.0) GOTO 160
	IF (ALEG(1).LT.0.0) THEN
		X1=ABS(XLEN)+0.2
		Y1=(YLEN-NB*ABS(ALEG(1)))*0.5
	ELSE
		X1=ALEG(2)
		Y1=ALEG(3)
	ENDIF
	DO 225 I=1,NS
C
C	MAKE SHADING BOX
C
		W(1)=X1
		W(2)=Y1
		W(3)=X1+ABS(ALEG(1))
		W(4)=Y1
		W(5)=X1+ABS(ALEG(1))
		W(6)=Y1+ABS(ALEG(1))
		W(7)=X1
		W(8)=Y1+ABS(ALEG(1))
		XX=X1+ABS(ALEG(1))+0.12
		YY=Y1+(ABS(ALEG(1))-CS)*0.5
		AN=0.0
		IF(JF.EQ.2)CALL PLOT(FLOAT(ICOL(I+6)),0.,0)
		IL=10
		CALL SHADE(W(1),W(2),4,2,1,ABS(DIS),AN,
     $			W(9),IL,0.,1.,0.,1.)
		IF (ISH(I).EQ.0) GOTO 220
		AN=45.0*(MOD(ISH(I)-1,4)-1)
		IL=0
		IF (ISH(I).GT.4.AND.ISH(I).LT.11) IL=1
		CALL SHADE(W(1),W(2),4,2,2,ABS(DIS),AN,
     $			W(9),IL,0.,1.,0.,1.)
		IF (ISH(I).GT.8) THEN
		    AN=AN+90.
		    IL=1
		    IF (ISH(I).GT.10) IL=0
		    CALL SHADE(W(1),W(2),4,2,2,ABS(DIS),AN,
     $			W(9),IL,0.,1.,0.,1.)
		ENDIF
220		CONTINUE
C
C	ADD SEGMENT LEGEND LABELS
C
		IF (NSLAB.NE.0) THEN
		   IF (DIS.LT.0.0) CALL NEWPEN(10*IWT(4))
		   IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(5)),0.,0)
		   CALL SYMBOL(XX,YY,CS,%REF(SLAB(I)),0.,NSLAB,-1)
		ENDIF
		Y1=Y1+ABS(ALEG(1))*1.2
225	CONTINUE
C
C	ADD TITLES
C
160	CONTINUE
	IF (NBT.GT.0) THEN
		IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(4)),0.,0)
	        IF (DIS.LT.0.0) CALL NEWPEN(IWT(4)*10)
		X1=0.
		Y1=0.
		CALL SYMBOL(X1,Y1,CS,BT,0.,NBT,-3)
		IF (JFF.NE.1) THEN		! VERTICAL
			X1=0.5*(ABS(XLEN)-X1)
			Y1=-3.0*CS
			CALL SYMBOL(X1,Y1,CS,BT,0.,NBT,-1)
		ELSE				! HORIZONTAL BARS
			Y1=0.5*(YLEN-X1)
			X1=-CS*3.0
			CALL SYMBOL(X1,Y1,CS,BT,90.,NBT,-1)
		ENDIF
	ENDIF
	IF (NLT.GT.0) THEN
		IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(4)),0.,0)
	        IF (DIS.LT.0.0) CALL NEWPEN(IWT(4)*10)
		X1=0.
		Y1=0.
		CALL SYMBOL(X1,Y1,CS,LT,0.,NLT,-3)
		IF (JFF.NE.1) THEN		! VERTICAL
			Y1=0.5*(YLEN-X1)
			X1=-AM-CS
			CALL SYMBOL(X1,Y1,CS,LT,90.,NLT,-1)
		ELSE				! HORIZONTAL BARS
			X1=0.5*(ABS(XLEN)-X1)
			Y1=-3.0*CS
			CALL SYMBOL(X1,Y1,CS,LT,0.,NLT,-1)
		ENDIF
	ENDIF
	IF (JF.EQ.2) CALL PLOT(FLOAT(ICOL(1)),0.,0)
	IF (NT.GT.0) THEN
		AN=-AN
	        IF (DIS.LT.0.0) CALL NEWPEN(IWT(6)*10)
		CALL SYMBOL(AN,YLEN+0.1,ABS(TCS),T,0.,NT,-1)
	ENDIF
C
C	FINISH UP
C
200	CONTINUE
	IF (DIS.LT.0.0) CALL NEWPEN(10)		!RESTORE LINETYPE/WIDTH
	CALL PLOT(0.,0.,3)			!PEN UP
	IF (IFLAG.GT.0) THEN
		CALL CTERM(2)			!CLEAR TERMINAL
		CALL PLOTND			!CLOSE PLOT OUTPUT
		REPEAT=.FALSE.
	ENDIF
	IF (IFLAG.LT.0) THEN
		REPEAT=.TRUE.
		CALL CTERM(1)			!PUT TERMINAL IN TEXT MODE
	ENDIF
	RETURN
	END
C
C ************************************************************************
C
	SUBROUTINE LSPLOT(X,Y,NDP,NDL,IFLAG,F,C,NC)
C
C	ROUTINE FOR PLOTTING LINES
C
C	WRITTEN:  DGL SEPT. 1987
C
	DIMENSION X(NDP,NDL),Y(NDP,NDL),F(1),NC(1)
	CHARACTER*(*) C(1)
C
C	X	(R) X INPUT ARRAY DIMENSIONED X(NDP,NDL)
C		    NOTE: DEPENDING ON OPTIONS SELECTED, X
C		    ACTUALLY MAY BE DIMENSIONED X(NDP)
C	Y	(R) Y INPUT ARRAY DIMENSIONED Y(NDP,NDL)
C	NDP	(I) NUMBER OF POINTS PER LINE DIMENSION
C	NDL	(I) NUMBER OF LINES DIMENSION
C	IFLAG	(R) PLOTTING FLAG
C		    < 0 DON'T CLOSE PLOT PACKAGE
C		    = 0 CLOSE PLOT PACKAGE WITHOUT PLOTTING
C		    > 0 CLOSE PLOT PACKAGE
C		MAG > 10000 INIT PLOT PACKAGE
C	(HUNDRED'S) = SCREEN GRAPHICS DEVICE (SEE FRAME)
C	F	(R) OPTIONS ARRAY (DESCRIBED BELOW)
C	C	(R) TITLES ARRAY
C		     C(1) X AXIS TITLE
C		     C(2) Y AXIS TITLE
C		     C(3) CHART TITLE
C		     C(4) LEGEND TEXT FOR LINE 1 (IF LEGEND ENABLED)
C		     C(5) LEGEND TEXT FOR LINE 2 (IF LEGEND ENABLED)
C		     ...   ...
C	NC	(I) NUMBER OF CHARACTERS IN TITLE ARRAY
C		    NC(1) NUMBER OF CHARACTERS IN C(1)
C		    NC(2) NUMBER OF CHARACTERS IN C(2)
C		    ...    ...
C		    ETC.  NOTE: IF NC(I) IS ZERO C(I) IS NOT PLOTTED
C
C	THE ELEMENTS OF F ARE INTERPRETTED ACCORDING THE THE FOLLOWING:
C	DEFAULT VALUES ARE SHOWN IN SQUARE BRACKETS
C
C   INDEX OF F	VALUE    ACTION
C  ____________ _____   ___________________
C	1      0<.<=NDP NUMBER OF POINTS PLOTTED [NDP]
C 	2      0<.<=NDL NUMBER OF LINES PLOTTED [NL]
C	3	-1/0/1	X AUTO SCALING: 0=AUTO,SMOOTH; 1=AUTO,NOSMOOTH; -1=USER
C	4	XMIN    USER SUPPLIED SCALE VALUE (USED IF F(3)<0)
C	5	XMAX    USER SUPPLIED SCALE VALUE (USED IF F(3)<0)
C	6	-1/0/1	Y AUTO SCALING: 0=AUTO,SMOOTH; 1=AUTO,NOSMOOTH; -1=USER
C	7	YMIN    USER SUPPLIED SCALE VALUE (USED IF F(6)<0)
C	8	YMAX    USER SUPPLIED SCALE VALUE (USED IF F(6)<0)
C	9	0/1	USE X VALUES WITH Y VALUES: 0=ONLY FIRST LINE OF
C			X DATA USED FOR ALL Y LINES; 1=LINES OF X/Y USED
C	10	0/1	CONNECT PLOTTED POINTS: 0=YES; 1=NO
C	11	>=0	SYMBOL PLOTTED EVERY ()TH POINT: 0=NO SYMBOLS
C	12	>=0	SYMBOL SIZE [0.1]: 0=USE DEFAULT
C	13	>=0	SYMBOL NUMBER FOR FIRST DATA LINE
C	14     -8<.<8	SHOW ERROR BARS: 0=NO ERROR BARS
C			WHEN NON-ZERO, CHANGES INTERPRETATION OF LINES
C			POINTS EVERY THIRD LINE ARE PLOTTED.  RELATIVE
C			ERROR (UPPER,LOWER) ARE THE FOLLOWING TWO LINES.
C			PLOTTED RELATIVE ERROR COMPUTED AS SUM OF FIRST
C			LINE PLUS SECOND/THIRD.
C		  <0    AN X IS MADE AT THE CENTER POINT
C
C		ABS(.)  TYPE OF ERROR BAR
C		------  ---------------------------------------------------
C		  1	LINE CONNECTING 2ND/3RD RELATIVE ERRORS
C		  2	1+HORIZONTAL BARS OF WIDTH EBAR AT 2ND/3RD REL ERR
C		  3	1+VERTICAL BARS OF WIDTH EBAR AT 2ND/3RD REL ERR
C		  4	2 LINES SPACED EBAR/2+HORIZONTAL BARS WIDTH=EBAR
C		  5	2 LINES SPACED EBAR/2+VERTICAL BARS WIDTH=EBAR
C		  6	VERTICAL RECTANGLE FROM 2ND/3RD WITH WIDTH=EBAR
C		  7     RECTANGLE WITH CORNER AT 2ND/3RD REL ERROR
C
C	16	>=0	ERROR BAR SIZE [0.1]: 0=DEFAULT USED
C	17	0/1	VERTICAL DRAWN LINE FROM POINT TO REFERENCE VALUE:
C			0=NO; 1=YES
C	18		REFERENCE VALUE
C	19	-1/0/1	X AXIS TYPE: 0=LINEAR; 1=LOG AXIS, -1=NO AXIS
C	20	-1/0/1	Y AXIS TYPE: 0=LINEAR; 1=LOG AXIS, -1=NO AXIS
C	21	>=0	X AXIS LENGTH [7.0]: 0=DEFAULT USED
C	22	>=0	Y AXIS LENGTH [5.0]: 0=DEFAULT USED
C	23	>=0	X AXIS TICK PATTERN (SEE AXIS3) [7.00]: 0=DEFAULT
C	24	>=0	Y AXIS TICK PATTERN (SEE AXIS3) [5.00]: 0=DEFAULT
C	25	0/1	X AXIS TITLE SIDE OF AXIS: 0=BELOW; 1=ABOVE
C	26	0/1	Y AXIS TITLE SIDE OF AXIS: 0=LEFT; 1=RIGHT
C	27	0/1	X AXIS AUTO EXPONENT ENABLE: 0=ENABLE; 1=DISABLE
C	28	0/1	Y AXIS AUTO EXPONENT ENABLE: 0=ENABLE; 1=DISABLE
C	29	0/1	X AXIS TICK SIDE: 0=BELOW; 1=ABOVE
C	30	0/1	Y AXIS TICK SIDE: 0=LEFT; 1=RIGHT
C	31	0/1	X AXIS NUMBERS ORIENTATION: 0=HORIZONTAL; 1=VERTICAL
C	32	0/1	Y AXIS NUMBERS ORIENTATION: 0=VERTICAL; 0=HORIZONTAL
C	33	0/1	X AXIS NUMBERS/TITLE SHWON: 0=SHOWN; 1=NOT SHOWN
C	34	0/1	Y AXIS NUMBERS/TITLE SHWON: 0=SHOWN; 1=NOT SHOWN
C	35	0/1	TAKE LOG10(ABS(X VALUES)+1.E-34): 0=NO; 1=YES
C	36	0/1	TAKE LOG10(ABS(Y VALUES)+1.E-34): 0=NO; 1=YES
C	37	-1/0/1	ADD MIRROR X AXIS: 0=NO; 1=WITH LABELS; -1:W/O LABELS
C	38	-1/0/1	ADD MIRROR Y AXIS: 0=NO; 1=WITH LABELS; -1:W/O LABELS
C	39	>=0	X AXIS LABEL SIZE [0.15]: 0=USE DEFAULT
C	40	>=0	Y AXIS LABEL SIZE [0.15]: 0=USE DEFAULT
C	41	>=0	TOP TITLE CHARACTER SIZE [0.18]: 0=USE DEFAULT
C	42	0/1/2/3	GRID OPTION: 0=NO GRID; 1=SOLID; 2=DOTTED; 3=TICKED
C	43	-1/0/1	LINE/SYMBOL LEGEND: 0=NO LEGEND; 1=AUTO PLACE; -1=USER
C	44	X	USER SPECIFIED LOWER-LEFT CORNER OF LEGEND
C	45	Y	USER SPECIFIED LOWER-LEFT CORNER OF LEGEND
C	46	0/1	SHOW PLOT SYMBOL WITH LEGEND: 0=NO; 1=YES
C	47	0/1	SHOW LINE SEGMENT ON LEGEND: 0=NO; 1=YES
C	48	>=0	LEGEND CHARACTER HEIGHT [0.12]: 0=USE DEFAULT
C	49	>=0	LEGEND SEGMENT LENGTH [0.5]: 0=USE DEFAULT
C	50	-1/0/1	TOP TITLE JUSTIFY: 0=CENTER; -1:LEFT; 1:RIGHT
C	51	0/1	PLOT HORIZONTAL REFERENCE LINE: 0=NO; 1=YES
C	52	0/1	USE LINE TYPE ARRAY VALUES: 0=NO; 1=YES
C	53	0/1	USE COLOR ARRAY VALUES: 0=NO; 1=YES
C	54	>=0	COLOR INDEX 1: 0=COLOR 1 USED
C	55	>=0	LINETYPE INDEX 1
C	56	>=0	COLOR INDEX 2: 0=COLOR 1 USED
C	57	>=0	LINETYPE INDEX 2
C	...		... ETC ...
C
C	INDEX		COLOR USAGE	LINETYPE USAGE
C	-------		------------    --------------
C	  1	        X AXIS		X AXIS
C	  2	      X AXIS NUMBERS	Y AXIS
C	  3	      X AXIS TITLE	TITLE
C	  4	      X AXIS EXPONENT	LEGEND TITLES
C	  5		Y AXIS		ZERO REF LINETYPE
C	  6	      Y AXIS NUMBERS	ERROR BAR LINETYPES
C	  7	      Y AXIS TITLE	LINE 1 LINETYPE
C	  8	      Y AXIS EXPONENT     ETC.
C	  9	        TITLE		  ...
C	 10		LEGEND TITLES	  ...
C	 11		ZERO REF LINE	  ...
C	 12		GRID COLOR	  ...
C	 13		LINE 1 COLOR	  ...
C	...		... ETC. ...      ...
C
	DIMENSION IC(4),SMO(2)
	LOGICAL REPEAT
	DATA REPEAT/.FALSE./
C
C	INTIALIZE ROUTINE AND PLOT PACKAGE IF REQUIRED
C
	IF (IFLAG.EQ.0) THEN
		IF (REPEAT) CALL PLOTND		!CLOSE PLOTTER
		REPEAT=.FALSE.
		RETURN
	ENDIF
C
C	INTIALIZE PLOT PACKAGE
C
	JF=IABS(IFLAG)
	IF (.NOT.REPEAT.AND.JF.LT.10000) THEN
		JF=JF/100			!GRAPHICS DEVICE CODE
		CALL FRAME(3,JF,1.5,1.0,1.)	!INTIALIZE
	ELSE
		CALL CTERM(-1)			!PUT TERMINAL IN PLOT MODE
	ENDIF
C
C	ESTABLISH DEFAULTS
C
	NP=NDP				! NUMBER OF POINTS/LINE
	NL=NDL				! NUMBER OF LINES
	XM=X(1,1)			! MIN X VALUE
	XX=XM				! MAX X VALUE
	YM=Y(1,1)			! MIN Y VALUE
	YX=YM				! MAX Y VALUE
	FX=5.01				! X AXIS NUMBER FORMAT
	FY=5.01				! Y AXIS NUMBER FORMAT
	XLEN=7.0			! X AXIS LENGTH
	YLEN=5.0			! Y AXIS LENGTH
	XTICK=7.0			! X AXIS TICK PATTERN
	YTICK=6.0			! Y AXIS TICK PATTERN
	XCS=0.15			! X AXIS TITLE SIZE
	YCS=0.15			! Y AXIS TITLE SIZE
	TCS=0.18			! OVERALL TITLE SIZE
	EBAR=0.1			! ERROR BAR SIZE
	SYMSIZ=0.1			! SYMBOL SIZE
	CSLEG=0.12			! LEGEND CHARACTER SIZE
	GLEN=0.5			! LEGEND LINE LENGTH
	XLEG=XLEN+0.3
	YLEG=0.5
C
C	READ OPTIONS ARRAY 
C
	IF (F(1).GT.0.0) NP=F(1)	! NUMBER OF POINT/LINE
	IF (NP.GT.NDP) NP=NDP
	IF (F(2).GT.0.0) NL=F(2)	! NUMBER OF LINES
	IF (NL.GT.NDL) NL=NDL
	JXAUTO=F(3)			! AUTO SCALE X, 0=YES/SMOOTH,-1=NO/USER
C					  1=YES/NO SMOOTH
	IF (JXAUTO.LT.0.0) THEN		! INPUT X AXIS SCALE FACTORS
		XM=F(4)				! MIN X (OTHERWISE RETURNED)
		XX=F(5)				! MAX X
	ENDIF
	JYAUTO=F(6)			! AUTO SCALE Y, 0=YES/SMOOTH,-1=NO/USER
C					  1=YES/NO SMOOTH
	IF (JYAUTO.LT.0.0) THEN		! INPUT Y AXIS SCALE FACTORS
		YM=F(7)				! MIN Y (OTHERWISE RETURNED)
		YX=F(8)				! MAX Y
	ENDIF
	JXUSE=ABS(F(9))			! USE X LINES WITH Y LINES,0=NO,1=YES
	JCONN=ABS(F(10))		! CONNECT POINTS WITH LINES,0=YES,1=NO
	JSYM=ABS(F(11))			! PLOT SYMBOL EVERY JSYM PT,0=NO SYMS
	IF (F(12).GT.0.0) SYMSIZ=F(12)	! SYMBOL SIZE
	JSYMST=ABS(F(13))		! STARTING PLOT SYMBOL NUMBER
	JEBAR=F(14)			! TYPE OF ERROR BAR,0=NOT USED
C
C		|JEBAR|  ERROR BAR (CLINE IS LINE CONNECT 2ND/3RD REL. ERR)
C		-------  ---------------------------------------------------
C		  1	  CLINE
C		  2	  CLINE+HORIZONTAL BARS WIDTH=EBAR
C		  3	  CLINE+VERTICAL BARS WIDTH=EBAR
C		  4	  DOUBLE CLINE+HORIZONTAL BARS WIDTH=EBAR
C		  5	  DOUBLE CLINE+VERTICAL BARS WIDTH=EBAR
C		  6	  VERTICAL RECTANGLE WIDTH=EBAR
C		  7       RECTANGLE DEFINED BY 2ND/3RD REL ERROR
C
C		NOTE: IF JBAR < 0 AN X (SIZE EBAR) IS USED TO MARK 1ST LINE
C
	KEBAR=IABS(JEBAR)
	NBAR=1
	IF (JEBAR.NE.0) NBAR=3
	IF (F(16).GT.0.0) EBAR=F(16)	! ERROR BAR SIZE
C					  1ST LINE DEFINES CENTER
C					  2ND IS LOWER REL. ERROR
C					  3RD IS UPPER REL. ERROR
	JVLINE=F(17)			! VERTICAL LINE TO ZVAL,0=NO,1=YES
	ZVAL=F(18)			! ZERO REFERENCE VALUE
	JXLGAX=F(19)			! X AXIS, LINEAR=0/LOG=1/NONE=-1
	JYLGAX=F(20)			! Y AXIS, LINEAR=0/LOG=1/NONE=-1
	IF (F(21).GT.0.0) XLEN=F(21)	! X AXIS LENGTH
	IF (F(22).GT.0.0) YLEN=F(22)	! Y AXIS LENGTH
	IF (F(23).GT.0.0) XTICK=F(23)	! X AXIS TICK PATTERN
	IF (F(24).GT.0.0) YTICK=F(24)	! Y AXIS TICK PATTERN
	JXTITLE=ABS(F(25))		! X AXIS TITLE SIDE,0=CW,1=CCW
	IF (JXTITLE.EQ.0) THEN
		JXTITLE=-1
	ELSE
		JXTITLE=1
	ENDIF
	JYTITLE=ABS(F(26))		! Y AXIS TITLE SIDE,0=CCW,1=CW
	IF (JYTITLE.EQ.0) THEN
		JYTITLE=1
	ELSE
		JYTITLE=-1
	ENDIF
	JXEXPSC=ABS(F(27))		! X AXIS ENABLE AUTO EXPONENT,0=YES,1=NO
	JYEXPSC=ABS(F(28))		! Y AXIS ENABLE AUTO EXPONENT,0=YES,1=NO
	JXTICKS=ABS(F(29))		! X AXIS TICKS TITLE SIDE,0=YES,1=NO
	JYTICKS=ABS(F(30))		! Y AXIS TICKS TITLE SIDE,0=YES,1=NO
	JXNUMS=ABS(F(31))		! X AXIS NUMS PARA AXIS, 0=YES,1=NO
	JYNUMS=ABS(F(32))		! Y AXIS NUMS PARA AXIS, 0=YES,1=NO
	JXNUM=ABS(F(33))		! X AXIS NUMS SHOWN, 0=YES,1=NO
	JYNUM=ABS(F(34))		! Y AXIS NUMS SHOWN, 0=YES,1=NO
	JXLOG=ABS(F(35))		! TAKE LOG OF X VALUES, 0=NO,1=YES
	JYLOG=ABS(F(36))		! TAKE LOG OF Y VALUES, 0=NO,1=YES
	JXRAX=F(37)		! ADD AXIS OPPOSITE, 0=YES,-1=W/L,1=NO LABELS
	JYRAX=F(38)		! ADD AXIS OPPOSITE, 0=YES,-1=W/L,1=NO LABELS
	IF (F(39).GT.0.0) XCS=F(39)	! X AXIS TITLE SIZE
	IF (F(40).GT.0.0) YCS=F(40)	! Y AXIS TITLE SIZE
	IF (F(41).GT.0.0) TCS=F(41)	! OVERALL TITLE SIZE
	JGRID=F(42)			! GRID OPTION, 0=NONE,1=SOLID,2=DOTTED
	JLEGND=F(43)			! ADD LEGEND, 0=NONE,1=AUTO,-1=USER
	IF (JLEGND.LT.0) XLEG=F(44)	! X LEGEND LOCATION
	IF (JLEGND.LT.0) YLEG=F(45)	! Y LEGEND LOCATION
	JLEGSY=F(46)			! USE SYMBOL ON LEGEND,0=NO,1=YES
	JLEGLI=F(47)			! USE LINETYPE ON LEGEND,0=NO,1=YES
	IF (F(48).GT.0.0) CSLEG=F(48)	! LEGEND CHARACTER SIZE
	IF (F(49).GT.0.0) GLEN=F(49)	! LEGEND LINE LENGTH
	JTCNTR=F(50)			! CENTER TITLE,0=YES,-1=LEFT,1=RIGHT
	JSZREF=F(51)			! SHOW ZERO REFERENCE,0=NO,1=YES
C
	JLINE=F(52)			! USE LINE TYPES,0=NO,1=YES
	JCOL=F(53)			! USE COLORS,0=NO,1=YES
C
C	F(54)=FIRST COLOR
C	F(55)=FIRST LINETYPE
C	F(56)=SECOND COLOR
C	F(57)=SECOND LINETYPE
C	...
C
	ICOFF=54
	ILOFF=55
C
C	COMPUTE SCALING
C
	IF (JXAUTO.GE.0) THEN		! AUTO SCALE X
		X1=ABS(XM)
		X2=X1
		DO 5 I=1,NP
			K=1
			IF (JXUSE.NE.0) K=NL
			DO 5 J=1,K,NBAR
				XM=MIN(XM,X(I,J))
				X1=MIN(X1,ABS(X(I,J)))
				XX=MAX(XX,X(I,J))
				X2=MAX(XX,ABS(X(I,J)))
				IF (JEBAR.NE.0.AND.JXUSE.NE.0) THEN
				    XM=MIN(XM,X(I,J)+X(I+1,J))
				    X1=MIN(X1,ABS(X(I,J)+X(I+1,J)))
				    XX=MAX(XX,X(I,J)+X(I+1,J))
				    X2=MAX(X2,ABS(X(I,J)+X(I+1,J)))
				    XM=MIN(XM,X(I,J)+X(I+2,J))
				    X1=MIN(X1,ABS(X(I,J)+X(I+1,J)))
				    XX=MAX(XX,X(I,J)+X(I+2,J))
				    X2=MAX(X2,ABS(X(I,J)+X(I+1,J)))
				ENDIF
 5		CONTINUE
		IF (JXLOG.NE.0) THEN
			XM=ALOG10(X1+1.E-34)
			XX=ALOG10(X2+1.E-34)
		ENDIF
		IF (JXAUTO.GT.0.AND.JXLGAX.EQ.0) THEN	! SMOOTH SCALING
			SMO(1)=XM
			SMO(2)=XX
			CALL SCALE(SMO,XLEN,2,1,1,XM,DX)
			XX=XM+XLEN*DX
		ENDIF
		IF (JXLGAX.NE.0) THEN			! LOG AXIS SCALING
			IF (XM.LE.0.AND.XM.NE.INT(XM)) XM=XM-1.0
			XM=INT(XM)
			IF (XX.GT.0.AND.XX.NE.INT(XX)) XX=XX+1.0
			XX=INT(XX)
		ENDIF
		IF (XX.EQ.XM) XX=XM+1.0
C	RETURN SCALE FACTORS USED
		F(4)=XM
		F(5)=XX
	ENDIF
	IF (JYAUTO.GE.0) THEN		! AUTO SCALE Y
		Y1=ABS(YM)
		Y2=Y1
		DO 6 I=1,NP
			DO 6 J=1,NL,NBAR
				YM=MIN(YM,Y(I,J))
				Y1=MIN(Y1,ABS(Y(I,J)))
				YX=MAX(YX,Y(I,J))
				Y2=MAX(YX,ABS(Y(I,J)))
				IF (JEBAR.NE.0) THEN
				    YM=MIN(YM,Y(I,J)+Y(I+1,J))
				    Y1=MIN(Y1,ABS(Y(I,J)+Y(I+1,J)))
				    YX=MAX(YX,Y(I,J)+Y(I+1,J))
				    Y2=MAX(Y2,ABS(Y(I,J)+Y(I+1,J)))
				    YM=MIN(YM,Y(I,J)+Y(I+2,J))
				    Y1=MIN(Y1,ABS(Y(I,J)+Y(I+1,J)))
				    YX=MAX(YX,Y(I,J)+Y(I+2,J))
				    Y2=MAX(Y2,ABS(Y(I,J)+Y(I+1,J)))
				ENDIF
 6		CONTINUE
		IF (JYLOG.NE.0) THEN
			YM=ALOG10(Y1+1.E-34)
			YX=ALOG10(Y2+1.E-34)
		ENDIF
		IF (JYAUTO.GT.0.AND.JYLGAX.EQ.0) THEN	! SMOOTH SCALING
			SMO(1)=YM
			SMO(2)=YX
			CALL SCALE(SMO,YLEN,2,1,1,YM,DY)
			YX=YM+YLEN*DY
		ENDIF
		IF (JYLGAX.NE.0) THEN			! LOG AXIS SCALING
			IF (YM.LE.0.AND.YM.NE.INT(YM)) YM=YM-1.0
			YM=INT(YM)
			IF (YX.GT.0.AND.YX.NE.INT(YX)) YX=YX+1.0
			YX=INT(YX)
		ENDIF
		IF (YX.EQ.YM) YX=YM+1.0
C	RETURN SCALE FACTORS USED
		F(7)=YM
		F(8)=YX
	ENDIF
	DX=(XX-XM)/XLEN
	DY=(YX-YM)/YLEN
C
C	PRODUCE PLOT X AXIS
C
	IF (JCOL.NE.0) THEN		! INITIALIZE COLOR AXIS ARRAY
		DO 10 I=1,4
			IC(I)=ABS(F(2*I+ICOFF-2))
			IF (IC(I).EQ.0) IC(I)=1
10		CONTINUE
	ENDIF
	IF (JLINE.NE.0) CALL NEWPEN(INT(F(ILOFF)))
C
	IF (JXEXPSC.NE.0) XCS=-XCS
	IF (JXLGAX.EQ.0) THEN		! LINEAR X AXIS
		X1=XLEN
		IF (JXTICKS.NE.0) X1=-XLEN
		NA=1000
		IF (JXNUM.NE.0) NA=NA+100
		IF (JCOL.NE.0) NA=NA+100000
		IF (JXNUMS.EQ.0) NA=NA-1000
		IF (NC(1).GT.0) THEN	! USE INPUT X AXIS TITLE
			NA=(NA+NC(1))*JXTITLE
			CALL AXIS3(0.,0.,%REF(C(1)),NA,X1,
     $				0.0,XM,XX,XTICK,XCS,FX,IC)
		ELSE			! NO X AXIS TITLE
			NA=(NA+1)*JXTITLE
			CALL AXIS3(0.,0.,' ',NA,X1,
     $				0.0,XM,XX,XTICK,XCS,FX,IC)
		ENDIF
		IF (JXRAX.NE.0) THEN
		    NA=1000
		    IF (JXRAX.GT.0) NA=NA+100
		    IF (JCOL.NE.0) NA=NA+100000
		    IF (JXNUMS.EQ.0) NA=NA-1000
		    IF (NC(1).GT.0) THEN! USE INPUT X AXIS TITLE
			NA=-(NA+NC(1))*JXTITLE
			CALL AXIS3(0.,YLEN,%REF(C(1)),NA,X1,
     $				0.0,XM,XX,XTICK,XCS,FX,IC)
		ELSE			! NO X AXIS TITLE
			NA=(NA+1)*JXTITLE
			CALL AXIS3(0.,YLEN,' ',NA,X1,
     $				0.0,XM,XX,XTICK,XCS,FX,IC)
		    ENDIF
		ENDIF
	ELSE IF (JXLGAX.EQ.1) THEN	! LOG X AXIS
		X1=XLEN
		IF (JXTICKS.NE.0) X1=-XLEN
		NA=1000
		IF (JXNUM.NE.0) NA=NA+100
		IF (JCOL.NE.0) NA=NA+10000
		IF (JXNUMS.EQ.0) NA=NA-1000
		IF (NC(1).GT.0) THEN	! USE INPUT X AXIS TITLE
			NA=(NA+NC(1))*JXTITLE
			CALL LGAXS(0.,0.,%REF(C(1)),NA,X1,
     $				0.0,XM,DX,IC)
		ELSE			! NO X AXIS TITLE
			NA=(NA+1)*JXTITLE
			CALL LGAXS(0.,0.,' ',NA,X1,
     $				0.0,XM,DX,IC)
		ENDIF
		IF (JXRAX.NE.0) THEN
		    NA=1000
		    IF (JXRAX.GT.0) NA=NA+100
		    IF (JCOL.NE.0) NA=NA+10000
		    IF (JXNUMS.EQ.0) NA=NA-1000
		    IF (NC(1).GT.0) THEN! USE INPUT X AXIS TITLE
			NA=-(NA+NC(1))*JXTITLE
			CALL LGAXS(0.,YLEN,%REF(C(1)),NA,X1,
     $				0.0,XM,DX,IC)
		    ELSE		! NO X AXIS TITLE
			NA=-(NA+1)*JXTITLE
			CALL LGAXS(0.,YLEN,' ',NA,X1,
     $				0.0,XM,DX,IC)
		    ENDIF
		ENDIF
	ENDIF
C
C	PRODUCE PLOT Y AXIS
C
	IF (JCOL.NE.0) THEN		! INITIALIZE COLOR AXIS ARRAY
		DO 20 I=1,4
			IC(I)=ABS(F(2*I+ICOFF+3))
			IF (IC(I).EQ.0) IC(I)=1
20		CONTINUE
	ENDIF
	IF (JLINE.NE.0) CALL NEWPEN(INT(F(ILOFF+1)))
C
	IF (JYEXPSC.NE.0) YCS=-YCS
	IF (JYLGAX.EQ.0) THEN		! LINEAR Y AXIS
		X1=YLEN
		IF (JYTICKS.NE.0) X1=-YLEN
		NA=1000
		IF (JYNUM.NE.0) NA=NA+100
		IF (JCOL.NE.0) NA=NA+100000
		IF (JYNUMS.EQ.0) NA=NA-1000
		IF (NC(2).GT.0) THEN	! USE INPUT Y AXIS TITLE
			NA=(NA+NC(2))*JYTITLE
			CALL AXIS3(0.,0.,%REF(C(2)),NA,X1,
     $				90.0,YM,YX,YTICK,YCS,FY,IC)
		ELSE			! NO Y AXIS TITLE
			NA=(NA+1)*JYTITLE
			CALL AXIS3(0.,0.,' ',NA,X1,
     $				90.0,YM,YX,YTICK,YCS,FY,IC)
		ENDIF
		IF (JYRAX.NE.0) THEN
		    NA=1000
		    IF (JYRAX.GT.0) NA=NA+100
		    IF (JCOL.NE.0) NA=NA+100000
		    IF (JYNUMS.EQ.0) NA=NA-1000
		    IF (NC(2).GT.0) THEN! USE INPUT Y AXIS TITLE
			NA=-(NA+NC(2))*JYTITLE
			CALL AXIS3(XLEN,0.,%REF(C(2)),NA,X1,
     $				90.0,YM,YX,YTICK,YCS,FY,IC)
		ELSE			! NO Y AXIS TITLE
			NA=(NA+1)*JYTITLE
			CALL AXIS3(XLEN,0.,' ',NA,X1,
     $				90.0,YM,YX,YTICK,YCS,FY,IC)
		    ENDIF
		ENDIF
	ELSE IF (JYLGAX.EQ.1) THEN	! LOG Y AXIS
		X1=YLEN
		IF (JYTICKS.NE.0) X1=-YLEN
		NA=1000
		IF (JYNUM.NE.0) NA=NA+100
		IF (JCOL.NE.0) NA=NA+10000
		IF (JYNUMS.EQ.0) NA=NA-1000
		IF (NC(2).GT.0) THEN	! USE INPUT Y AXIS TITLE
			NA=(NA+NC(2))*JYTITLE
			CALL LGAXS(0.,0.,%REF(C(2)),NA,X1,
     $				90.0,XY,DY,IC)
		ELSE			! NO X AXIS TITLE
			NA=(NA+1)*JYTITLE
			CALL LGAXS(0.,0.,' ',NA,X1,
     $				90.0,YM,DY,IC)
		ENDIF
		IF (JYRAX.NE.0) THEN
		    NA=1000
		    IF (JYRAX.GT.0) NA=NA+100
		    IF (JCOL.NE.0) NA=NA+10000
		    IF (JYNUMS.EQ.0) NA=NA-1000
		    IF (NC(2).GT.0) THEN! USE INPUT Y AXIS TITLE
			NA=-(NA+NC(2))*JYTITLE
			CALL LGAXS(XLEN,0.,%REF(C(2)),NA,X1,
     $				90.0,YM,DY,IC)
		    ELSE		! NO Y AXIS TITLE
			NA=-(NA+1)*JYTITLE
			CALL LGAXS(XLEN,0.,' ',NA,X1,
     $				90.0,YM,DY,IC)
		    ENDIF
		ENDIF
	ENDIF
C
C	PLOT GRID
C
	IF (JGRID.NE.0) THEN
		IF (JCOL.NE.0) THEN
		    ICC=INT(ABS(F(ICOFF+12)))
		    IF (ICC.LT.1) ICC=1
		    CALL PLOT(FLOAT(ICC),0.,0)
		ENDIF
		NG=JGRID-1
		I=INT(XTICK)-1
		IF (I.LT.1) I=1
		X1=XLEN/FLOAT(I)
		IF (JXLGAX.GT.0) THEN
			I=1-INT(XLEN*DX-XM+0.001)
			X1=-XLEN/FLOAT(I)
		ENDIF
		J=INT(YTICK)-1
		IF (J.LT.1) J=1
		Y1=YLEN/FLOAT(J)
		IF (JYLGAX.GT.0) THEN
			J=1-INT(YLEN*DY-YM+0.001)
			Y1=-YLEN/FLOAT(J)
		ENDIF
		CALL LGRID(0.,0.,X1,Y1,I,J,NG)
	ENDIF
C
C	ADD TITLE
C
	IF (NC(3).GT.0) THEN
		IF (JLINE.NE.0) CALL NEWPEN(INT(F(ILOFF+2)))
		IF (JCOL.NE.0) THEN
			ICC=INT(ABS(F(ICOFF+8)))
			IF (ICC.LT.1) ICC=1
			CALL PLOT(FLOAT(ICC),0.,0)
		ENDIF
		ICC=0
		X1=0.5*XLEN
		Y1=YLEN+0.1+TCS*0.2
		IF (JTCNTR.LT.0) THEN
			ICC=-1
			X1=0.0
			Y1=Y1-TCS*0.2
		ENDIF
		IF (JTCNTR.GT.0) THEN
			ICC=1
			X1=XLEN
			Y1=Y1-TCS*0.2
		ENDIF
		IF (JXRAX.LT.0) Y1=Y1+2.5*XCS
		CALL SYMBOL(X1,Y1,TCS,%REF(C(3)),
     $			0.0,NC(3),ICC)
	ENDIF
C
C	PLOT DATA IN DESIRED FORM
C
	DX=1.0
	DY=1.0
	IF (XX-XM.NE.0.0) DX=XLEN/(XX-XM)
	IF (YX-YM.NE.0.0) DY=YLEN/(YX-YM)
	ZREF=(ZREF-YM)*DY
	IF (JSZREF.NE.0) THEN	! SHOW ZERO REFERENCE LINE
		IF (JLINE) CALL NEWPEN(INT(F(ILOFF+10)))
		IF (JCOL.NE.0) THEN
			ICC=INT(ABS(F(ICOFF+10+I)))
			IF (ICC.LT.1) ICC=1
			CALL PLOT(FLOAT(ICC),0.,0)
		ENDIF
		CALL PLOT(0.0,ZREF,3)
		CALL PLOT(XLEN,ZREF,2)
	ENDIF
	DO 100 I=1,NL,NBAR
		IF (JLINE) CALL NEWPEN(INT(F(I+ILOFF+6)))
		IF (JCOL.NE.0) THEN
			ICC=INT(ABS(F(ICOFF+12+I)))
			IF (ICC.LT.1) ICC=1
			CALL PLOT(FLOAT(ICC),0.,0)
		ENDIF
		KSYM=MOD(I+JSYMST-1,17)
C
C	IF WE NEED CONNECTING LINES MAKE A CONNECT PASS
C
		IPEN=3
		IF (JCONN.EQ.0) THEN
		    DO 50 J=1,NP
			IF (JXUSE.NE.0) THEN
				X1=X(J,I)
			ELSE
				X1=X(J,1)
			ENDIF
			IF (JXLOG.NE.0) X1=ALOG10(ABS(X1)+1.E-34)
			X1=(X1-XM)*DX
			Y1=Y(J,I)
			IF (JYLOG.NE.0) Y1=ALOG10(ABS(Y1)+1.E-34)
			Y1=(Y1-YM)*DY
			CALL PLOT(X1,Y1,IPEN)
			IPEN=2
 50		    CONTINUE
		ENDIF
C
C	ANOTHER PASS FOR SYMBOLS, ETC.
C
		IF (JCONN.NE.0.AND.JEBAR.EQ.0.AND.JVLINE.EQ.0
     $			.AND.JSYM.EQ.0) GOTO 100
		ISYM=0
		DO 60 J=1,NP
			IF (JXUSE.NE.0) THEN
				X1=X(J,I)
			ELSE
				X1=X(J,1)
			ENDIF
			IF (JXLOG.NE.0) X1=ALOG10(ABS(X1)+1.E-34)
			X1=(X1-XM)*DX
			Y1=Y(J,I)
			IF (JYLOG.NE.0) Y1=ALOG10(ABS(Y1)+1.E-34)
			Y1=(Y1-YM)*DY
			IF (JSYM.NE.0) THEN		! SYMBOLS
			    IF (MOD(ISYM,JSYM).EQ.0) CALL
     $			SYMBOL(X1,Y1,SYMSIZ,FLOAT(KSYM),0.,-1,-1)
			ENDIF
			IF (JVLINE.NE.0) THEN		! VERTICAL LINE
				CALL PLOT(X1,Y1,3)
				CALL PLOT(X1,ZREF,2)
			ENDIF
			IF (JEBAR.NE.0) THEN		! ERROR BAR
			    IF (JLINE) CALL NEWPEN(INT(F(ILOFF+5)))
			    IF (JXUSE.NE.0) THEN
				X2=X(J,I+1)+X(J,I)
				X3=X(J,I+2)+X(J,I)
			        IF (JXLOG.NE.0) THEN
				    X2=ALOG10(ABS(X2)+1.E-34)
				    X3=ALOG10(ABS(X3)+1.E-34)
				ENDIF
				X2=(X2-XM)*DX
				X3=(X3-XM)*DX
			    ELSE
				X2=X1
				X3=X1
			    ENDIF
			    Y2=Y(J,I+1)+Y(J,I)
			    Y3=Y(J,I+2)+Y(J,I)
			    IF (JYLOG.NE.0) THEN
				Y2=ALOG10(ABS(Y2)+1.E-34)
				Y3=ALOG10(ABS(Y3)+1.E-34)
			    ENDIF
			    Y2=(Y2-YM)*DY
			    Y3=(Y3-YM)*DY
			    IF (KEBAR.EQ.2.OR.KEBAR.EQ.5) THEN	! ERROR BAR TOP
				CALL PLOT(X2,Y2-EBAR,3)
				CALL PLOT(X2,Y2+EBAR,2)
			    ELSE IF (KEBAR.EQ.3.OR.KEBAR.EQ.4) THEN
				CALL PLOT(X2-EBAR,Y2,3)
				CALL PLOT(X2+EBAR,Y2,2)
			    ENDIF
			    IF (KEBAR.LT.4) THEN	! CONNECT LINE
				CALL PLOT(X2,Y2,3)
				CALL PLOT(X3,Y3,2)
			    ELSE IF (KEBAR.EQ.4) THEN	! DOUBLE CONN V LINE
				CALL PLOT(X2-EBAR*0.5,Y2,3)
				CALL PLOT(X3-EBAR*0.5,Y3,2)
				CALL PLOT(X3+EBAR*0.5,Y3,3)
				CALL PLOT(X2+EBAR*0.5,Y2,2)
			    ELSE IF (KEBAR.EQ.5) THEN	! DOUBLE CONN HLINE
				CALL PLOT(X2,Y2-EBAR*0.5,3)
				CALL PLOT(X3,Y3-EBAR*0.5,2)
				CALL PLOT(X3,Y3+EBAR*0.5,3)
				CALL PLOT(X2,Y2+EBAR*0.5,2)
			    ELSE IF (KEBAR.EQ.6) THEN	! VERTICAL RECT
				CALL RECT(X1-EBAR,Y2,X1+EVAR,Y3)
			    ELSE IF (KEBAR.EQ.7) THEN	! RECT
				CALL RECT(X2,Y2,X3,Y3)
			    ENDIF
			    IF (JEBAR.LT.0) THEN	! X MARK
				CALL PLOT(X1-EBAR,Y1-EBAR,3)
				CALL PLOT(X1+EBAR,Y1+EBAR,2)
				CALL PLOT(X1-EBAR,Y1+EBAR,3)
				CALL PLOT(X1+EBAR,Y1-EBAR,2)
			    ENDIF
			    IF (KEBAR.EQ.2.OR.KEBAR.EQ.5) THEN	! BAR BOTTOM
				CALL PLOT(X3,Y3-EBAR,3)
				CALL PLOT(X3,Y3+EBAR,2)
			    ELSE IF (KEBAR.EQ.3.OR.KEBAR.EQ.4) THEN
				CALL PLOT(X3-EBAR,Y3,3)
				CALL PLOT(X3+EBAR,Y3,2)
			    ENDIF
			ENDIF
			IF (JSYM.EQ.0.AND.JCONN.EQ.0.AND.
     $			    JEBAR.EQ.0.AND.JVLINE.EQ.0) THEN
				CALL PLOT(X1,Y1,3)	! DOTS ONLY
				CALL PLOT(X1,Y1,2)
			ENDIF
			ISYM=ISYM+1
 60		    CONTINUE
100	CONTINUE
C
C	ADD LEGEND
C
	IF (JLEGND.NE.0) THEN
		DO 200 I=1,NL
			X1=XLEG+CSLEG*1.5
			Y1=YLEG+(I-1)*CSLEG*1.5+CSLEG*0.5
			IF (JCOL.NE.0) THEN
			    ICC=INT(ABS(F(ICOFF+12+1)))
			    IF (ICC.LT.1) ICC=1
			    CALL PLOT(FLOAT(ICC),0.,0)
			ENDIF
			IF (JLEGLI.NE.0) THEN
		    	    IF (JLINE)CALL NEWPEN(INT(F(I+ILOFF+6)))
			    CALL PLOT(X1,Y1,3)
			    CALL PLOT(X1+GLEN,Y1,2)
			    X1=X1+GLEN*0.5
			ENDIF
			IF (JLEGSY.NE.0) THEN
			    ICC=I-1+JYSMST
			    CALL SYMBOL(X1,Y1,SYMSIZ,
     $					FLOAT(ICC),0.,-1,-1)
			ENDIF
			IF (JLEGLI.NE.0) X1=X1+GLEN*0.5
			X1=X1+CSLEG*0.7
			Y1=Y1-CSLEG*0.5
			IF (NC(I+3).GT.0) THEN
			    IF (JLINE) CALL NEWPEN(INT(F(ILOFF+3)))
			    IF (JCOL.NE.0) THEN
				ICC=INT(ABS(F(ICOFF+9)))
				IF (ICC.LT.1) ICC=1
				CALL PLOT(FLOAT(ICC),0.,0)
			    ENDIF
			    CALL SYMBOL(X1,Y1,CSLEG,
     $				%REF(C(I+3)),0.,NC(I+3),-1)
			ENDIF
200		CONTINUE
	ENDIF
C
C	FINISH UP
C
	CALL PLOT(0.,0.,3)			!PEN UP
	IF (IFLAG.GT.0) THEN
		CALL CTERM(2)			!CLEAR TERMINAL
		CALL PLOTND			!CLOSE PLOT OUTPUT
		REPEAT=.FALSE.
	ENDIF
	IF (IFLAG.LT.0) THEN
		REPEAT=.TRUE.
		CALL CTERM(1)			!PUT TERMINAL IN TEXT MODE
	ENDIF
	RETURN
	END
C
C ************************************************************************
C
	SUBROUTINE SFPLOT
C
C	PLANNED MASTER ROUTINE
C
	RETURN
	END
